import { CubeRegion } from "@sapi-game/gameRegion/gameRegion";
import { DimensionIds } from "@sapi-game/utils/vanila-data";
import { EleloadState } from "@/elevatorCat/loadState/state";
import { elevatorCatModule } from "@/elevatorCat/module";
import { Elevator } from "./components/elevator";
import { ElevatorController } from "./components/elevatorController";
import { ElevatorDoorComponent } from "./components/elevatorDoor";
import { ElevatorViewComponent } from "./components/elevatorView";
import { ElevatorMainDaemon } from "./components/daemon";
import { BlockInteractionBlocker } from "@sapi-game/gameComponent/player/blockInteractionBlocker";
import { EntityInteractionBlocker } from "@sapi-game/gameComponent/player/entityInteractionBlocker";
import { BlockComponentTypes } from "@minecraft/server";

export class eleMainState extends elevatorCatModule.State {
    readonly eleList = [
        new Elevator({
            baseLoc: { x: 361, y: -60, z: 47 },
            region: new CubeRegion(
                DimensionIds.Overworld,
                { x: 361, y: -60, z: 47 },
                { x: 358, y: 28, z: 44 }
            ),
            maxFloor: 11,
            initFloor: 1,
        }),
        new Elevator({
            baseLoc: { x: 361, y: -60, z: 40 },
            region: new CubeRegion(
                DimensionIds.Overworld,
                { x: 361, y: -60, z: 40 },
                { x: 358, y: 28, z: 37 }
            ),
            maxFloor: 11,
            initFloor: 10,
        }),
    ];

    override onEnter(): void {
        this.addComponent(ElevatorController)
            .addComponent(ElevatorDoorComponent)
            .addComponent(ElevatorViewComponent)
            .addComponent(ElevatorMainDaemon)
            .addComponent(BlockInteractionBlocker, {
                groupSet: this.context.group,
                blockComponentType: BlockComponentTypes.Inventory,
            })
            .addComponent(EntityInteractionBlocker, {
                groupSet: this.context.group,
                entityIds: ["minecraft:armor_stand"],
            });

        //进入等待阶段
        this.pushState(EleloadState);
    }
}
